<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    <input type="text" id="txt">
    <ul id="list">
    </ul>
</body>
<script>
    const otxt = document.getElementById("txt")
    const olist = document.getElementById("list")

    const url = "https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su";

    otxt.oninput = function(){
        if(this.value === ""){
            olist.innerHTML = "";
            return;
        }
        
        // 处理要想百度发送的数据
        const str = `wd=${this.value}&cb=ajshfgsajdg`;
        // 创建script标签，将数据拼接到url，准备jsonp请求
        const script = document.createElement("script");
        script.src = url + "?" + str;
        document.body.appendChild(script);

        window.ajshfgsajdg = function(res){
            console.log(res.s);
            let str = "";
            for(let i=0;i<res.s.length;i++){
                str += `<li>${res.s[i]}</li>`
            }
            olist.innerHTML = str;
        }
    }


</script>
</html>